package org.darkforest.common.services.impl;

import org.darkforest.common.services.StatService;
import org.darkforest.dao.mapper.*;
import org.darkforest.model.StatOrderGoods;
import org.darkforest.model.Store;
import org.darkforest.model.StoreJoinIn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by valentina on 15/6/26.
 */
@Service
public class StatServiceImpl implements StatService{

    @Autowired
    private MemberMapper memberMapper;
    @Autowired
    private GoodsCommonMapper goodsCommonMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private ProxyMapper proxyMapper;
    @Autowired
    private StatOrderGoodsMapper statOrderGoodsMapper;
    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private StoreJoinInMapper storeJoinInMapper;


    @Override
    public Integer getMemberCount(Integer nearTime) {
        return memberMapper.getMemberCount(nearTime);
    }

    @Override
    public Integer getGoodsCount(Integer nearTime) {
        return goodsCommonMapper.getGoodsCount(nearTime);
    }

    @Override
    public Integer getOrderCount(Integer nearTime) {
        return orderMapper.getOrderCount(nearTime);
    }

    @Override
    public Integer getProxyCount(Integer nearSecond,Integer state) {
        Map<String,Integer> param = new HashMap<String,Integer>();
        param.put("nearSecond",nearSecond);
        param.put("state",state);
        return proxyMapper.getProxyCount(param);
    }

    /**
     * 店铺统计
     * @param
     * @return
     */
    public Integer getStoreCount(Integer state){
        Store record = new Store();
        List<Store> list = storeMapper.findStoreByCondition(record);
        return list!=null?list.size():0;
    }
    /**
     * 审核店铺
     * @param
     * @return
     */
    public Integer getStoreJoinCount(Integer state){
        StoreJoinIn storeJoinIn = new StoreJoinIn();
        List<StoreJoinIn> list = storeJoinInMapper.selectCheckStoreJoinIn(storeJoinIn);
        return list!=null?list.size():0;
    }

    @Override
    public List<String> findYListByXList(List<String> xLists) {
        return statOrderGoodsMapper.findYListByXList(xLists);
    }

    @Override
    public List<StatOrderGoods> findYListByStortId(Integer storeId) {
        return statOrderGoodsMapper.findYListByStortId(storeId);
    }

    @Override
    public StatOrderGoods findstatisticalByStortId(Integer storeId) {
        return statOrderGoodsMapper.findstatisticalByStortId(storeId);
    }
}
